/// @tags: Mid PriorityQueue
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>

using std::cin, std::cout, std::endl;
using std::priority_queue, std::vector;

namespace BlueQuantum {

typedef long long ll;

priority_queue<int, vector<int>, std::less<int> > q1;
priority_queue<int, vector<int>, std::greater<int> > q2;

int main() {
  ll sum1 = 0, sum2 = 0, sumb = 0;
  int q;
  cin >> q;
  while (q--) {
    int opt;
    cin >> opt;
    if (opt == 1) {
      int a, b;
      cin >> a >> b;
      sumb += b;
      if (!q1.size() || a < q1.top())
        q1.push(a), sum1 += a;
      else
        q2.push(a), sum2 += a;
      while (q1.size() < q2.size()) {
        int tmp = q2.top();
        q2.pop(), q1.push(tmp);
        sum1 += tmp, sum2 -= tmp;
      }
      while (q1.size() - 1 > q2.size()) {
        int tmp = q1.top();
        q1.pop(), q2.push(tmp);
        sum1 -= tmp, sum2 += tmp;
      }
    } else {
      cout << q1.top() << ' '
           << q1.top() * (ll)q1.size() - sum1 + sum2 -
                  q1.top() * (ll)q2.size() + sumb
           << endl;
    }
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("ABC 127F.in", "r", stdin);
  freopen("ABC 127F.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
